home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / tex / aaai-named-0.98.bst < prev    next >
Encoding:
BibTeX style  |  1988-04-18  |  39.8 KB  |  1,547 lines

  1. % BibTeX `named' style-file version 1
  2. %    for BibTeX version 0.98i or later, LaTeX version 2.09
  3. %    by Peter F. Patel-Schneider
  4. % This style is NOT guaranteed to work.  It is provided in the hope
  5. % that it will make the preparation of papers for AAAI-87 easier. 
  6. %
  7. % There are undoubtably bugs in this style.  If you make bug fixes,
  8. % improvements, etc.  please let me know.  My e-mail address is:
  9. %    pfps@spar.slb.com
  10. %
  11. % Modified from:
  12. % BibTeX standard bibliography style `alpha'
  13.     % version 0.98c for BibTeX versions 0.98i or later, LaTeX version 2.08
  14.     % Copyright (C) 1985, all rights reserved
  15.     % Copying of this file is authorized only if either
  16.     % (1) you make absolutely no changes to your copy, including name, or
  17.     % (2) if you do make changes, you name it something other than
  18.     % btxbst.doc, plain.bst, unsrt.bst, alpha.bst, and abbrv.bst
  19.     % This restriction helps ensure that all standard styles are identical
  20. %
  21. %   Entry formatting: Similar to that recommended by Mary-Claire van Leunen
  22. %    in "A Handbook for Scholars".  Book-like titles are italicized,
  23. %    non-book titles are converted to sentence capitilization
  24. %    (and not enclosed in quotes).  Either the "open" or the "closed"
  25. %    format can be used, with the appropriate definition of
  26. %    \newblock (the name \newblock is analogous to the names \newline
  27. %    and \newpage).  The "open" format has a line break before each
  28. %    major block of an entry, and lines after the first are indented
  29. %    within blocks.  The "closed" format just runs the blocks
  30. %    together.  This file outputs a \newblock between blocks.
  31. %    It uses the closed format.
  32. %
  33. %   Citation format: [author-last-name, year]
  34. %             [author-last-name and author-last-name, year]
  35. %             [author-last-name {\em et al.}, year]
  36. %
  37. %   Reference list ordering: alphabetical by author or whatever passes
  38. %    for author in the absence of one.
  39. %
  40. % This BibTeX style has support for short (year only) citations.  This
  41. % is done by having the citations actually look like
  42. %         \citename{name-info, }year
  43. % The LaTeX style has to have the following
  44. %     \let\@internalcite\cite
  45. %     \def\cite{\def\citename##1{##1}\@internalcite}
  46. %     \def\shortcite{\def\citename##1{}\@internalcite}
  47. %     \def\@biblabel#1{\def\citename##1{##1}[#1]\hfill}
  48. % which makes \shortcite the macro for short citations.
  49.  
  50. %   History
  51. %   12/16/84    (HWT)    Original version, by Howard Trickey.
  52. %   12/23/84    (LL)    Some comments made by Leslie Lamport.
  53. %    2/12/85    (OP)    Changes based primarily on LL's comments
  54. %    1/07/85    (pfps)    Change to named style plus some enhancements.
  55. %    9/15/85    (pfps)  Added support for short (year only) citations.
  56.  
  57. % The ENTRY declaration
  58. %   Like Scribe's (according to pages 231-2 of the April '84 edition),
  59. %   but no fullauthor or editors fields because BibTeX does name handling.
  60. %   The annote field is commented out here because this isn't an annotated
  61. %   bibliography style
  62.  
  63. ENTRY {            % Fields:
  64.     address        % Publisher's address
  65. %    annote        % Long annotation used for annotated bibliographies
  66.             % (begins sentence)
  67.     author        % Name(s) of author(s), in BibTeX name format
  68.     booktitle        % Title of a book when the thing being referenced
  69.             % isn't the whole book.  For book entries, the title
  70.             % field should be used instead.
  71.     chapter        % Chapter number
  72.     edition        % Edition of a book (e.g., "second")
  73.     editor        % Name(s) of editor(s), in BibTeX name format
  74.             % If there is also an author field, then the editor
  75.             % field should be for the book or collection that the
  76.             % work appears in
  77.     howpublished    % How something strange has been published
  78.             % (begins sentence)
  79.     institution        % Sponsoring institution
  80.     journal        % Journal name (macros are provided for many)
  81.     key            % Alphabetizing (and perhaps labeling) key
  82.             % (needed when no author or editor)
  83.     location        % Location for a conference
  84.     month        % Month (macros are provided)
  85.     note        % Help in finding a reference (begins sentence)
  86.     number        % Number of a journal or technical report
  87.     organization    % Organization (sponsoring a conference)
  88.     pages        % Page number or numbers (use `--' to separate a range)
  89.     publisher        % Publisher name
  90.     school        % School name (for theses)
  91.     series        % The name of a series or set of books; an individual
  92.             % book will will also have it's own title
  93.     title        % Title
  94.     type        % Type of a Techreport (e.g., "Research Note")
  95.             % to be used instead of default "Technical Report"
  96.     volume        % Volume of a journal or multivolume work
  97.     year        % Year
  98.   }
  99.   {}            % No integer entry variables
  100.   { label extralabel }    % String entry variables used to form citation label
  101.  
  102. % Each entry function starts by calling output.bibitem, to write the
  103. % \bibitem and its arguments to the .bbl file.  Then the various fields
  104. % are formatted and printed by output or output.check.  Those functions
  105. % handle the writing of separators (commas, periods, \newblock's),
  106. % taking care not to do so when they are passed a null string.
  107. % Finally, fin.entry is called to add the final period and finish the
  108. % entry.
  109. %
  110. % A bibliographic reference is formatted into a number of `blocks':
  111. % in the open format, a block begins on a new line and subsequent
  112. % lines of the block are indented.  A block may contain more than
  113. % one sentence (well, not a grammatical sentence, but something to
  114. % be ended with a sentence ending period).  The entry functions should
  115. % call new.block whenever a block other than the first is about to be
  116. % started.  They should call new.sentence whenever a new sentence is
  117. % to be started.  The output functions will ensure that if two
  118. % new.sentence's occur without any non-null string being output between
  119. % them then there won't be two periods output.  Similarly for two
  120. % successive new.block's.
  121.  
  122. % The output routines don't write their argument immediately.
  123. % Instead, by convention, that argument is saved on the stack to be
  124. % output next time (when we'll know what separator needs to come
  125. % after it).  Meanwhile, the output routine has to pop the pending
  126. % output off the stack, append any needed separator, and write it.
  127. %
  128. % To tell which separator is needed, we maintain an output.state.
  129. % It will be one of these values:
  130. %    before.all        just after the \bibitem
  131. %    mid.sentence        in the middle of a sentence: comma needed
  132. %                    if more sentence is output
  133. %    after.sentence        just after a sentence: period needed
  134. %    after.block        just after a block (and sentence):
  135. %                    period and \newblock needed.
  136. % Note: This style (plain) doesn't use after.sentence
  137. %
  138. % VAR: output.state : INTEGER        -- state variable for output
  139. %
  140. % The output.nonnull function saves its argument (assumed to be nonnull)
  141. % on the stack, and writes the old saved value followed by any needed
  142. % separator.  The ordering of the tests is decreasing frequency of
  143. % occurrence.
  144. %
  145. % output.nonnull(s) ==
  146. %  BEGIN
  147. %    s := argument on stack
  148. %    if output.state = mid.sentence then
  149. %        write$(pop() * ", ")
  150. %          -- "pop" isn't a function: just use stack top
  151. %    else
  152. %        if output.state = after.block then
  153. %        write$(add.period$(pop()))
  154. %        newline$
  155. %        write$("\newblock ")
  156. %        else
  157. %        if output.state = before.all then
  158. %            write$(pop())
  159. %        else        -- output.state should be after.sentence
  160. %            write$(add.period$(pop()) * " ")
  161. %        fi
  162. %        fi
  163. %    fi
  164. %    push s on stack
  165. %    output.state := mid.sentence
  166. %  END
  167. %
  168. % The output function calls output.nonnull if its argument is non-null
  169. %
  170. % output(s) ==
  171. %  BEGIN
  172. %    if s <> "" then output.nonnull(s)
  173. %    fi
  174. %  END
  175. %
  176. % The output.check function calls output.nonnull if s is non-null
  177. % and warns the user that the t field shouldn't be empty (this is
  178. % because it won't be a good reference without the field;  the entry
  179. % functions try to make the formatting look reasonable even when such
  180. % fields are empty).
  181. %
  182. % output.check(t,s) ==
  183. %  BEGIN
  184. %    if s = "" then
  185. %        top$("Warning: the " * t * " shouldn't be empty in " * cite$)
  186. %    else output.nonnull(s)
  187. %    fi
  188. %  END
  189. %
  190. % The output.bibitem function writes the \bibitem for the current entry
  191. % (the label should already have been set up), and sets up the separator
  192. % state for the output functions.  And, it leaves a string on the stack
  193. % as per the output convention.
  194. %
  195. % output.bibitem ==
  196. %  BEGIN
  197. %    newline$
  198. %    write$("\bibitem[")    % for nonnumeric labels,
  199. %    write$(label)        % these three lines should be used
  200. %    write$("]{")        % instead of the following line
  201. %    write$("\bibitem{")
  202. %    write$(cite$)
  203. %    write$("}")
  204. %    push "" on stack
  205. %    output.state := before.all
  206. %  END
  207. %
  208. % The fin.entry function finishes off an entry by adding a period to the
  209. % string remaining on the stack.  If the state is still before.all
  210. % then nothing was produced for this entry, so the result will look bad,
  211. % but the user deserves it. (We don't omit the whole entry because the
  212. % entry was cited, and a bibitem is needed to define the citation label.)
  213. %
  214. % fin.entry ==
  215. %  BEGIN
  216. %    write$(add.period$(pop()))
  217. %    newline$
  218. %  END
  219. %
  220. % The new.block function prepares for a new block to be output, and
  221. % new.sentence prepares for a new sentence.
  222. %
  223. % new.block ==
  224. %  BEGIN
  225. %    if output.state <> before.all then
  226. %        output.state := after.block
  227. %    fi
  228. %  END
  229. %
  230. % new.sentence ==
  231. %  BEGIN
  232. %    if output.state <> after.block then
  233. %        if output.state <> before.all then
  234. %        output.state :=  after.sentence
  235. %        fi
  236. %    fi
  237. %  END
  238. %
  239.  
  240. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  241.  
  242. FUNCTION{init.state.consts}
  243. { 'before.all #0 :=
  244.   'mid.sentence #1 :=
  245.   'after.sentence #2 :=
  246.   'after.block #3 :=
  247. }
  248.  
  249. STRINGS { s t }            % temporary string holders
  250.  
  251. FUNCTION{output.nonnull}
  252. { 's swap$ :=
  253.   output.state mid.sentence =
  254.     { ", " * write$
  255.     }
  256.     { output.state after.block =
  257.     { add.period$ write$
  258.       newline$
  259.       "\newblock " write$
  260.     }
  261.     { output.state before.all =
  262.         { write$ }
  263.         { add.period$ " " * write$ }
  264.       if$
  265.     }
  266.       if$
  267.     }
  268.   if$
  269.   'output.state mid.sentence :=
  270.   s
  271. }
  272.  
  273. FUNCTION{output}
  274. { 's swap$ :=
  275.   s "" =
  276.     'skip$
  277.     { s output.nonnull
  278.     }
  279.   if$
  280. }
  281.  
  282. FUNCTION{output.check}
  283. { 's swap$ :=
  284.   't swap$ :=
  285.   s "" =
  286.     { "Warning: the " t * " shouldn't be empty in " * cite$ * top$
  287.     }
  288.     { s output.nonnull
  289.     }
  290.   if$
  291. }
  292.  
  293. FUNCTION{output.bibitem}
  294. { newline$
  295.   "\bibitem[" write$    % for nonnumeric labels,
  296.   label write$        % these three lines should be used
  297.   "]{" write$        % instead of the following line
  298. %  "\bibitem{" write$                - pfps
  299.   cite$ write$
  300.   "}" write$
  301.   newline$
  302.   ""
  303.   'output.state before.all :=
  304. }
  305.  
  306. % This function finishes all entries.  Note: For an otherwise empty entry
  307. % (which is probably due to a user error) this function prints a period
  308.  
  309. FUNCTION{fin.entry}
  310. { add.period$
  311.   write$
  312.   newline$
  313. }
  314.  
  315. FUNCTION{new.block}
  316. { output.state before.all =
  317.     'skip$
  318.     { 'output.state after.block := }
  319.   if$
  320. }
  321.  
  322. % This function isn't used in this style (plain)
  323.  
  324. FUNCTION{new.sentence}
  325. { output.state after.block =
  326.     'skip$
  327.     { output.state before.all =
  328.     'skip$
  329.     { 'output.state after.sentence := }
  330.       if$
  331.     }
  332.   if$
  333. }
  334.  
  335. % These three functions pop one or two (integer) arguments from the stack
  336. % and push a single one, either 0 or 1.
  337.  
  338. FUNCTION{not}
  339. {   { #0 }
  340.     { #1 }
  341.   if$
  342. }
  343.  
  344. FUNCTION{and}
  345. {   'skip$        % the corresponding if$ would be idempotent
  346.     { pop$ #0 }
  347.   if$
  348. }
  349.  
  350. FUNCTION{or}
  351. {   { pop$ #1 }
  352.     'skip$        % the corresponding if$ would be idempotent
  353.   if$
  354. }
  355.  
  356. % Here are some functions for formatting chunks of an entry.
  357. % By convention they either produce a string that can be followed by
  358. % a comma or period (using add.period$, so it is OK to end in a period),
  359. % or they produce the null string.
  360. %
  361. % A useful utility is the field.or.null function, which checks if the
  362. % argument is the result of pushing a `missing' field (one for which no
  363. % assignment was made when the current entry was read in from the database),
  364. % and returns the null string if so, otherwise it returns the field string.
  365. %
  366. % field.or.null(s) ==
  367. %  BEGIN
  368. %    if missing$(s) then return ""
  369. %    else return s
  370. %  END
  371. %
  372. % Another helper function is italicize, which returns the string that
  373. % italicizes the argument string, if that is non-null, otherwise it
  374. % returns the null string.  Italic corrections aren't used, so this
  375. % function should be used when punctation will follow the result.
  376. % Also, it needn't be \em (instead of \it) because the user shouldn't be
  377. % emphasizing the whole bibliography.
  378. %
  379. % italicize(s) ==
  380. %  BEGIN
  381. %    if s = "" then return ""
  382. %    else return "{\it " * s * "}"
  383. %
  384. % The format.names function formats the argument (which should be in
  385. % BibTeX name format) into "First Von Last, Junior", separated by commas
  386. % and with an "and" before the last.
  387. %
  388. % VAR: nameptr, namesleft, numnames: INTEGER
  389. %      nameresult: STRING
  390. %
  391. % format.names(s) ==
  392. %  BEGIN
  393. %    nameptr := 1
  394. %    nameresult := ""
  395. %    numnames := num.names$(s)
  396. %    namesleft := numnames
  397. %    while namesleft > 0
  398. %      do
  399. %        if nameptr > 1 then
  400. %        if namesleft > 0 then nameresult := nameresult * ", "
  401. %        else if numnames > 2
  402. %               then nameresult := nameresult * ", and "
  403. %               else nameresult := nameresult * " and "
  404. %             fi
  405. %        fi
  406. %        fi
  407. %        nameresult := nameresult *
  408. %        format.names$(s, nameptr, "{ff }{vv }{ll}{, jj}")
  409. %        nameptr := nameptr + 1
  410. %      od
  411. %    return nameresult
  412. %  END
  413. %
  414. % The format.authors function returns the result of format.names(author)
  415. % if the author is present, or else it returns the null string
  416. %
  417. % format.authors ==
  418. %  BEGIN
  419. %    if missing$(author) then return ""
  420. %    else return format.names(author)
  421. %    fi
  422. %  END
  423. %
  424. % Format.editors is like format.authors, but it uses the editor field,
  425. % and appends ", editor" or ", editors"
  426. %
  427. % format.editors ==
  428. %  BEGIN
  429. %    if missing$(editor) then return ""
  430. %    else
  431. %        if num.names$(editor) > 1 then
  432. %        return format.names(editor) * ", editors"
  433. %        else
  434. %        return format.names(editor) * ", editor"
  435. %        fi
  436. %    fi
  437. %  END
  438. %
  439. % Other formatting functions are similar, so no "comment version" will be
  440. % given for them.
  441.  
  442. FUNCTION{field.or.null}
  443. { duplicate$
  444.   missing$
  445.     { pop$    % a way to get the duplicate `missing' value off
  446.       ""
  447.     }
  448.     'skip$    % the duplicate is the return value
  449.   if$
  450. }
  451.  
  452. FUNCTION{italicize}
  453. { 's swap$ :=
  454.   s "" =
  455.     { "" }
  456.     { "{\it " s * "}" * }
  457.   if$
  458. }
  459.  
  460. INTEGERS{ nameptr namesleft numnames }
  461.  
  462. STRINGS{ nameresult }
  463.  
  464. FUNCTION{format.names}
  465. { 's swap$ :=
  466.   'nameptr #1 :=
  467.   'nameresult "" :=
  468.   'numnames s num.names$ :=
  469.   'namesleft numnames :=
  470.     { namesleft #0 > }
  471.     { 'namesleft namesleft #1 - :=
  472.       nameptr #1 >
  473.     { namesleft #0 >
  474.         { 'nameresult nameresult ", " * :=}
  475.         { numnames #2 >
  476.         { 'nameresult nameresult ", and " * :=}
  477.         { 'nameresult nameresult " and " * :=}
  478.           if$
  479.         }
  480.       if$
  481.     }
  482.     'skip$
  483.       if$
  484.       'nameresult
  485.       nameresult
  486.       s nameptr "{ff }{vv }{ll}{, jj}" format.name$
  487.       *
  488.     :=
  489.       'nameptr nameptr #1 +  :=
  490.     }
  491.   while$
  492.   nameresult    % return the result
  493. }
  494.  
  495. FUNCTION{format.authors}
  496. { author missing$
  497.     {""}
  498.     {author format.names}
  499.   if$
  500. }
  501.  
  502. FUNCTION{format.editors}
  503. { editor missing$
  504.     { ""
  505.     }
  506.     {
  507.       editor num.names$ #1 >
  508.     { editor format.names ", editors" * }
  509.     { editor format.names ", editor" * }
  510.       if$
  511.     }
  512.   if$
  513. }
  514.  
  515. % The format.title function is used for non-book-like titles.  We convert to
  516. % lowercase (except for the very first letter), and hope the user has
  517. % brace-surrounded words that need to stay capitilized.
  518.  
  519. FUNCTION{format.title}
  520. { title missing$
  521.     { "" }
  522.     { title "ul" change.case$ }
  523.   if$
  524. }
  525.  
  526. % The entry.string.max function is set to BibTeX's ent_str_size constant,
  527. % the maximum length of an entry string variable.
  528. %
  529. % The global.string.max function is set to BibTeX's glob_str_size constant,
  530. % the maximum length of a global string variable.
  531.  
  532. FUNCTION{entry.string.max} { #100 }
  533.  
  534. FUNCTION{global.string.max} { #300 }
  535.  
  536. % The n.dashify function makes each single `-' in a string a double `--'
  537. % if it's not already
  538. %
  539. % VAR: pageresult: STRING
  540. %
  541. % n.dashify(s) ==
  542. %  BEGIN
  543. %    t := s
  544. %    pageresult := ""
  545. %    while (not (t = ""))
  546. %      do
  547. %        if (first character of t = "-")
  548. %          then
  549. %        if (next character isn't)
  550. %          then
  551. %            pageresult := pageresult * "--"
  552. %            t := t with the "-" removed
  553. %          else
  554. %            while (first character of t = "-")
  555. %              do
  556. %            pageresult := pageresult * "-"
  557. %            t := t with the "-" removed
  558. %              od
  559. %        fi
  560. %          else
  561. %        pageresult := pageresult * the first character
  562. %        t := t with the first character removed
  563. %        fi
  564. %      od
  565. %    return pageresult
  566. %  END
  567.  
  568. STRINGS{ pageresult }
  569.  
  570. FUNCTION{n.dashify}
  571. { 't swap$ :=
  572.   'pageresult "" :=
  573.     { t "" = not }
  574.     { t #1 #1 substring$ "-" =
  575.     { t #1 #2 substring$ "--" = not
  576.         { 'pageresult pageresult "--" * :=
  577.           't t #2 global.string.max substring$ :=
  578.         }
  579.         {   { t #1 #1 substring$ "-" =}
  580.         { 'pageresult pageresult "-" * :=
  581.           't t #2 global.string.max substring$ :=
  582.         }
  583.           while$
  584.         }
  585.       if$
  586.     }
  587.     { 'pageresult pageresult t #1 #1 substring$ * :=
  588.       't t #2 global.string.max substring$ :=
  589.     }
  590.       if$
  591.     }
  592.   while$
  593.   pageresult
  594. }
  595.  
  596. % The format.vol.num.pages function is for the volume, number, and page range
  597. % of a journal article.  We use the format:  vol(number):pages
  598.  
  599. FUNCTION{format.vol.num.pages}
  600. { volume field.or.null
  601.   number missing$
  602.     { booktitle missing$
  603.         { "" }
  604.     { "(" booktitle * ")" * }
  605.       if$
  606.     }
  607.     { "(" number *
  608.       booktitle missing$
  609.         { "" }
  610.     { ", " booktitle * }
  611.       if$
  612.       * ")" *
  613.     }
  614.   if$
  615.   *
  616.   pages missing$
  617.     { "" }
  618.     { ":" pages n.dashify * }
  619.   if$
  620.   *
  621. }
  622.  
  623. % The format.date function is for the month and year, but we give a warning if
  624. % there's a missing year but the month is there, and we return the empty string
  625. % if they're both missing
  626.  
  627. FUNCTION{format.date}
  628. { year missing$
  629.     { month missing$
  630.     { "" }
  631.     { "Warning: there's a month but no year in " cite$ * top$
  632.       month
  633.     }
  634.       if$
  635.     }
  636.     { month missing$
  637.     { year }
  638.     { month " " * year * }
  639.       if$
  640.     }
  641.   if$
  642. }
  643.  
  644. % The format.btitle is for formatting the title field when it is a book-like
  645. % entry---the style used here keeps it in uppers-and-lowers and italicizes it.
  646.  
  647. FUNCTION{format.btitle}
  648. { title field.or.null
  649.   italicize
  650. }
  651.  
  652. % The format.bvolume function is for formatting the volume number and/or
  653. % series name of a multivolume book.  If the volume field is missing, we
  654. % output either the series field italicized if it exists or the null string
  655. % otherwise.  If both the volume and series fields are there, we assume the
  656. % series field is the title of the whole multivolume work (the title field
  657. % should be the title of the one referred to), and add an "of <series>".
  658. % A tie (~) is put between the "Volume" and the volume number.
  659. % We capitilize Volume because this function is used at the beginning of a
  660. % block.
  661.  
  662. FUNCTION{format.bvolume}
  663. { volume missing$
  664.     { series missing$
  665.     { "" }
  666.     { series italicize }
  667.       if$
  668.     }
  669.     { "Volume~" volume *
  670.       series missing$
  671.     'skip$
  672.     { " of " * series italicize * }
  673.       if$
  674.     }
  675.   if$
  676. }
  677.  
  678. % The format.edition function appends " edition" to the edition, if present.
  679. % We lowercase the edition (it should be something like "Third"), because
  680. % this doesn't start a sentence.
  681.  
  682. FUNCTION{format.edition}
  683. { edition missing$
  684.     { "" }
  685.     { edition "ll" change.case$ " edition" * }
  686.   if$
  687. }
  688.  
  689. % The format.pages function is used for formatting a page range in a book.
  690. % The multi.page.check function examines the page field for a "-" or a ","
  691. % so that format.pages can use "page" instead of "pages" if neither exists.
  692. % Note: global.string.max, set above, here means "take the rest of the string"
  693. %
  694. % VAR: multiresult: INTEGER    (actually, a boolean)
  695. %
  696. % multi.page.check(s) ==
  697. %  BEGIN
  698. %    t := s
  699. %    multiresult := false
  700. %    while ((not multiresult) and (not (t = "")))
  701. %      do
  702. %        if (first character of t = "-" or ",")
  703. %          then multiresult := true
  704. %          else t := t with the first character removed
  705. %        fi
  706. %      od
  707. %    return multiresult
  708. %  END
  709.  
  710. INTEGERS{ multiresult }
  711.  
  712. FUNCTION{multi.page.check}
  713. { 't swap$ :=
  714.   'multiresult #0 :=
  715.     { multiresult not
  716.       t "" = not
  717.       and
  718.     }
  719.     { t #1 #1 substring$ "-" =
  720.       t #1 #1 substring$ "," =
  721.       or
  722.     { 'multiresult #1 := }
  723.     { 't t #2 global.string.max substring$ := }
  724.       if$
  725.     }
  726.   while$
  727.   multiresult
  728. }
  729.  
  730. FUNCTION{format.pages}
  731. { pages missing$
  732.     { "" }
  733.     { pages multi.page.check
  734.     { "pages~" pages n.dashify * }
  735.     { "page~" pages n.dashify * }
  736.       if$
  737.     }
  738.   if$
  739. }
  740.  
  741. % The format.chapter.pages puts "chapter~" in front of a chapter number,
  742. % if present, and then appends the pages, if present.
  743. % This doesn't begin a sentence.
  744.  
  745. FUNCTION{format.chapter.pages}
  746. { chapter missing$
  747.     { format.pages }
  748.     { "chapter~" chapter *
  749.       pages missing$
  750.     'skip$
  751.     { ", " * format.pages * }
  752.       if$
  753.     }
  754.   if$
  755. }
  756.  
  757. % The format.in.ed.booktitle function is used for starting out a sentence
  758. % that begins "In <booktitle>", putting an editor before the title if one
  759. % exists.
  760.  
  761. FUNCTION{format.in.ed.booktitle}
  762. { booktitle missing$
  763.     { ""
  764.     }
  765.     { 's format.editors :=
  766.       s "" =
  767.     { "In " booktitle italicize * }
  768.     { "In " s * ", " * booktitle italicize * }
  769.       if$
  770.     }
  771.   if$
  772. }
  773.  
  774. % The format.in.techreport function is used for starting out a sentence
  775. % that begins "In <techreport>"
  776.  
  777. FUNCTION{format.in.techreport}
  778. { booktitle missing$
  779.     { "" }
  780.     { "In " booktitle * }
  781.   if$
  782. }
  783.  
  784. % The format.tr.number makes a string starting with "Technical Report"
  785. % (or type, if that field is defined), followed by the number if there
  786. % is one (but return the first part even if there is no number)
  787.  
  788. FUNCTION{format.tr.number}
  789. { type missing$
  790.     { "Technical Report" }
  791.     { type }
  792.   if$
  793.   number missing$
  794.     'skip$
  795.     { "~" * number * }
  796.   if$
  797. }
  798.  
  799. % Now we define the type functions for all entry types that may appear
  800. % in the .BIB file -- e.g., functions like `book' and `article'.  These
  801. % are the routines that actually generate the .BBL file output for
  802. % the entry.  In addition, the style designer should have a function
  803. % `default.type' for unknown types.  Note: The fields (within each list)
  804. % are listed in order of appearance.
  805. %
  806. % The article function is for an article in a journal.
  807. %    Required fields: author, title, journal, year
  808. %    Optional fields: volume, number, pages, month, note
  809. %
  810. % article ==
  811. %  BEGIN
  812. %    output.bibitem
  813. %    output.check("author",format.authors)
  814. %    new.block
  815. %    output.check("title",format.title)
  816. %    new.block
  817. %    output.check("journal",italicize(field.or.null(journal)))
  818. %    output(format.vol.num.pages)
  819. %    output.check("year",format.date)
  820. %    new.block
  821. %    output(field.or.null(note))
  822. %    fin.entry
  823. %  END
  824. %
  825. % The book function is for a whole book.
  826. %    Required fields: author or editor, title, publisher, year
  827. %    Optional fields: volume, series, address, edition, month, note
  828. %
  829. % book ==
  830. %  BEGIN
  831. %    if missing$(author) then output.check("author and editor",
  832. %                                format.editors)
  833. %    else output.check("author",format.authors)
  834. %    fi
  835. %    new.block
  836. %    output.check("title",format.btitle)
  837. %    new.block
  838. %    output(format.bvolume)
  839. %    output.check("publisher",field.or.null(publisher))
  840. %    output(field.or.null(address))
  841. %    output(format.edition)
  842. %    output.check("year",format.date))
  843. %    new.block
  844. %    output(field.or.null(note))
  845. %    fin.entry
  846. %  END
  847. %
  848. % The other entry functions are all quite similar, so no "comment version"
  849. % will be given for them.
  850.  
  851. FUNCTION{article}
  852. { output.bibitem
  853.   "author" format.authors output.check
  854.   new.block
  855.   "title" format.title output.check
  856.   new.block
  857.   "journal" journal field.or.null italicize output.check
  858.   format.vol.num.pages output
  859.   "year" format.date output.check
  860.   new.block
  861.   note field.or.null output
  862.   fin.entry
  863. }
  864.  
  865. FUNCTION{book}
  866. { output.bibitem
  867.   author missing$
  868.     { "author and editor" format.editors output.check
  869.     }
  870.     { "author" format.authors output.check
  871.     }
  872.   if$
  873.   new.block
  874.   "title" format.btitle output.check
  875.   new.block
  876.   format.bvolume output
  877.   "publisher" publisher field.or.null output.check
  878.   address field.or.null output
  879.   format.edition output
  880.   "year" format.date output.check
  881.   new.block
  882.   note field.or.null output
  883.   fin.entry
  884. }
  885.  
  886. % The booklet function is for bound things without publishers or
  887. % sponsoring institutions
  888. %    Required: title
  889. %    Optional: author, howpublished, address, month, year, note
  890.  
  891. FUNCTION{booklet}
  892. { output.bibitem
  893.   format.authors output
  894.   new.block
  895.   "title" format.btitle output.check
  896.   new.block
  897.   howpublished field.or.null output
  898.   address field.or.null output
  899.   format.date output
  900.   new.block
  901.   note field.or.null output
  902.   fin.entry
  903. }
  904.  
  905. % For the conference entry type, see inproceedings
  906.  
  907. % An inbook is a piece of a book: either a chapter or a page range.
  908. %    Required: author or editor, title, chapter or pages, publisher, year
  909. %    Optional: volume, series, address, edition, month, note
  910.  
  911. FUNCTION{inbook}
  912. { output.bibitem
  913.   author missing$
  914.     { "author and editor" format.editors output.check
  915.     }
  916.     { "author" format.authors output.check
  917.     }
  918.   if$
  919.   new.block
  920.   "title" format.btitle output.check
  921.   "chapter and pages" format.chapter.pages output.check
  922.   new.block
  923.   format.bvolume output
  924.   "publisher" publisher field.or.null output.check
  925.   address field.or.null output
  926.   format.edition output
  927.   "year" format.date output.check
  928.   new.block
  929.   note field.or.null output
  930.   fin.entry
  931. }
  932.  
  933. % An incollection is like inbook, but where there is a separate title
  934. % for the referenced thing (and perhaps an editor for the whole)
  935. %    Required: author, title, booktitle, publisher, year
  936. %    Optional: editor, chapter, pages, address, month, note
  937.  
  938. FUNCTION{incollection}
  939. { output.bibitem
  940.   "authors" format.authors output.check
  941.   new.block
  942.   "title" format.title output.check
  943.   new.block
  944.   "booktitle" format.in.ed.booktitle output.check
  945.   format.chapter.pages output
  946.   "publisher" publisher field.or.null output.check
  947.   address field.or.null output
  948.   "year" format.date output.check
  949.   new.block
  950.   note field.or.null output
  951.   fin.entry
  952. }
  953.  
  954. % An intechreport is almost the same as an incollection
  955. FUNCTION{intechreport}
  956. { output.bibitem
  957.   "authors" format.authors output.check
  958.   new.block
  959.   "title" format.title output.check
  960.   new.block
  961.   "booktitle" format.in.techreport output.check
  962.   format.chapter.pages output
  963.   format.tr.number output
  964.   "insitution" institution field.or.null output.check
  965.   address field.or.null output
  966.   "year" format.date output.check
  967.   new.block
  968.   note field.or.null output
  969.   fin.entry
  970. }
  971.  
  972. % An inproceedings is an article in a conference proceedings
  973. %    Required: author, title, booktitle, year
  974. %    Optional: editor, pages, organization, publisher, address,
  975. %          month, note, location
  976.  
  977. FUNCTION{inproceedings}
  978. { output.bibitem
  979.   "author" format.authors output.check
  980.   new.block
  981.   "title" format.title output.check
  982.   new.block
  983.   "booktitle" format.in.ed.booktitle output.check
  984.   format.pages output
  985.   location field.or.null output
  986.   organization field.or.null output
  987.   publisher field.or.null output
  988.   address field.or.null output
  989.   "year" format.date output.check
  990.   new.block
  991.   note field.or.null output
  992.   fin.entry
  993. }
  994.  
  995. % The conference function is included for Scribe compatibility
  996.  
  997. FUNCTION{conference} {inproceedings}
  998.  
  999. % A manual is technical documentation
  1000. %    Required: title
  1001. %    Optional: author, organization, address, edition, month, year, note
  1002.  
  1003. FUNCTION{manual}
  1004. { output.bibitem
  1005.   format.authors output
  1006.   new.block
  1007.   "title" format.btitle output.check
  1008.   new.block
  1009.   organization field.or.null output
  1010.   address field.or.null output
  1011.   format.edition output
  1012.   format.date output
  1013.   new.block
  1014.   note field.or.null output
  1015.   fin.entry
  1016. }
  1017.  
  1018. % A mastersthesis is a Master's thesis
  1019. %    Required: author, title, school, year
  1020. %    Optional: address, month, note
  1021.  
  1022. FUNCTION{mastersthesis}
  1023. { output.bibitem
  1024.   "author" format.authors output.check
  1025.   new.block
  1026.   "title" format.btitle output.check
  1027.   new.block
  1028.   "Master's thesis" output
  1029.   "school" school field.or.null output.check
  1030.   address field.or.null output
  1031.   "year" format.date output.check
  1032.   new.block
  1033.   note field.or.null output
  1034.   fin.entry
  1035. }
  1036.  
  1037. % a misc is something that doesn't fit elsewhere
  1038. %    Required: none
  1039. %    Optional: author, title, howpublished, month, year, note
  1040.  
  1041. FUNCTION{misc}
  1042. { output.bibitem
  1043.   format.authors output
  1044.   new.block
  1045.   format.title output
  1046.   new.block
  1047.   howpublished field.or.null output
  1048.   format.date output
  1049.   new.block
  1050.   note field.or.null output
  1051.   fin.entry
  1052. }
  1053.  
  1054. % A phdthesis is like a mastersthesis
  1055. %    Required: author, title, school, year
  1056. %    Optional: address, month, note
  1057.  
  1058. FUNCTION{phdthesis}
  1059. { output.bibitem
  1060.   "author" format.authors output.check
  1061.   new.block
  1062.   "title" format.btitle output.check
  1063.   new.block
  1064.   "PhD thesis" output
  1065.   "school" school field.or.null output.check
  1066.   address field.or.null output
  1067.   "year" format.date output.check
  1068.   new.block
  1069.   note field.or.null output
  1070.   fin.entry
  1071. }
  1072.  
  1073. % a proceedings is a conference proceedings
  1074. %    Required: editor or organization, title, year
  1075. %    Optional: publisher, address, month, note
  1076.  
  1077. FUNCTION{proceedings}
  1078. { output.bibitem
  1079.   editor missing$
  1080.     { "editor and organization" organization field.or.null output.check
  1081.     }
  1082.     { "editor" format.editors output.check
  1083.     }
  1084.   if$
  1085.   new.block
  1086.   "title" format.btitle output.check
  1087.   publisher field.or.null output
  1088.   address field.or.null output
  1089.   "year" format.date output.check
  1090.   new.block
  1091.   note field.or.null output
  1092.   fin.entry
  1093. }
  1094.  
  1095. % a techreport is a technical report.
  1096. %    Required: author, title, institution, year
  1097. %    Optional: type, number, address, month, note
  1098.  
  1099. FUNCTION{techreport}
  1100. { output.bibitem
  1101.   "author" format.authors output.check
  1102.   new.block
  1103.   "title" format.btitle output.check
  1104.   new.block
  1105.   format.tr.number output
  1106.   "institution" institution field.or.null output.check
  1107.   address field.or.null output
  1108.   "year" format.date output.check
  1109.   new.block
  1110.   note field.or.null output
  1111.   fin.entry
  1112. }
  1113.  
  1114. % an unpublished is something that hasn't been published
  1115. %    Required: author, title, note
  1116. %    Optional: month, year
  1117.  
  1118. FUNCTION{unpublished}
  1119. { output.bibitem
  1120.   "author" format.authors output.check
  1121.   new.block
  1122.   "title" format.title output.check
  1123.   new.block
  1124.   format.date output
  1125.   new.block
  1126.   "note" note field.or.null output.check
  1127.   fin.entry
  1128. }
  1129.  
  1130. % We use entry type book for an unknown type and give a warning
  1131.  
  1132. FUNCTION{default.type} {book}
  1133.  
  1134. % Here are macros for common things that may vary from style to style.
  1135. % Users are encouraged to use these macros.
  1136.  
  1137. % For this style (plain), months and journals are written out in full
  1138.  
  1139. MACRO{jan} {"January"}
  1140.  
  1141. MACRO{feb} {"February"}
  1142.  
  1143. MACRO{mar} {"March"}
  1144.  
  1145. MACRO{apr} {"April"}
  1146.  
  1147. MACRO{may} {"May"}
  1148.  
  1149. MACRO{jun} {"June"}
  1150.  
  1151. MACRO{jul} {"July"}
  1152.  
  1153. MACRO{aug} {"August"}
  1154.  
  1155. MACRO{sep} {"September"}
  1156.  
  1157. MACRO{oct} {"October"}
  1158.  
  1159. MACRO{nov} {"November"}
  1160.  
  1161. MACRO{dec} {"December"}
  1162.  
  1163. MACRO{acmcs} {"ACM Computing Surveys"}
  1164.  
  1165. MACRO{acta} {"Acta Informatica"}
  1166.  
  1167. MACRO{cacm} {"Communications of the ACM"}
  1168.  
  1169. MACRO{ibmjrd} {"IBM Journal of Research and Development"}
  1170.  
  1171. MACRO{ibmsj} {"IBM Systems Journal"}
  1172.  
  1173. MACRO{ieeese} {"IEEE Transactions on Software Engineering"}
  1174.  
  1175. MACRO{ieeetc} {"IEEE Transactions on Computers"}
  1176.  
  1177. MACRO{ieeetcad}
  1178.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  1179.  
  1180. MACRO{ipl} {"Information Processing Letters"}
  1181.  
  1182. MACRO{jacm} {"Journal of the ACM"}
  1183.  
  1184. MACRO{jcss} {"Journal of Computer and System Sciences"}
  1185.  
  1186. MACRO{scp} {"Science of Computer Programming"}
  1187.  
  1188. MACRO{sicomp} {"SIAM Journal on Computing"}
  1189.  
  1190. MACRO{tocs} {"ACM Transactions on Computer Systems"}
  1191.  
  1192. MACRO{tods} {"ACM Transactions on Database Systems"}
  1193.  
  1194. MACRO{tog} {"ACM Transactions on Graphics"}
  1195.  
  1196. MACRO{toms} {"ACM Transactions on Mathematical Software"}
  1197.  
  1198. MACRO{toois} {"ACM Transactions on Office Information Systems"}
  1199.  
  1200. MACRO{toplas} {"ACM Transactions on Programming Languages and Systems"}
  1201.  
  1202. MACRO{tsc} {"Theoretical Computer Science"}
  1203.  
  1204. % Now we read in the .BIB entries.
  1205.  
  1206. READ
  1207.  
  1208. % I CHANGED THIS SORTKEY TO BE BETTER - pfps
  1209. % Next we compute the sortkey by executing "presort" on each entry.
  1210. % The presort key contains a number of purified strings, concatenated
  1211. % with multiple blanks between them.  Since purify$ makes sure there will
  1212. % not be consecutive multiple blanks in its result, this makes things
  1213. % like "John  Jones" come before "John Green  Brown".
  1214. %
  1215. % The fields used here are: the author names (or editor names, if those
  1216. % are missing, or the key field if both are), WITH THE NUMBER OF NAMES
  1217. % HERE AFTER THE FIRST NAME, FOLLOWED BY THE YEAR, followed by the first bit
  1218. % of the title (chopping off a leading "The", "A", or "An").
  1219. % Names are formatted: Von Last First Junior, with the First names
  1220. % abbreviated.  Two blanks will separate the name parts (except the von
  1221. % and last), three will separate the names, and four will separate the
  1222. % names from the YEAR AND THE YEAR FROM THE title.
  1223.  
  1224. % The sort.format.names function takes an argument that should be in
  1225. % BibTeX name format, and returns a string containing "   "-separated
  1226. % names in the format described above.  The function is almost the same
  1227. % as format.names.
  1228.  
  1229. FUNCTION{sort.format.names}
  1230. { 's swap$ :=
  1231.   'nameptr #1 :=
  1232.   'nameresult "" :=
  1233.   'namesleft s num.names$ :=
  1234.     { namesleft #0 > }
  1235.     { 'namesleft namesleft #1 - :=
  1236.       nameptr #1 >
  1237.     { 'nameresult nameresult "   " * := }
  1238.     'skip$
  1239.       if$
  1240.       'nameresult
  1241.       nameresult
  1242.       s nameptr "{vv }{ll}{  f}{  jj}" format.name$
  1243.         "ll" change.case$
  1244.       purify$
  1245.       *
  1246.     :=
  1247.        nameptr #1 =
  1248.          { 'nameresult
  1249.         nameresult "   " * namesleft #1 + int.to.str$ *
  1250.        := }
  1251.      'skip$
  1252.        if$
  1253.       'nameptr nameptr #1 +  :=
  1254.     }
  1255.   while$
  1256.   nameresult    % return the result
  1257. }
  1258.  
  1259. % The chop.word(w,len,s) function returns either s or, if the first len
  1260. % letters of s equals w, it returns that part of s after w.
  1261.  
  1262. INTEGERS { len }
  1263.  
  1264. FUNCTION{chop.word}
  1265. { 's swap$ :=
  1266.   'len swap$ :=
  1267.   s #1 len substring$ =        % comparing against w, on the stack
  1268.     { s len #1 + global.string.max substring$ }
  1269.     { s }
  1270.   if$
  1271. }
  1272.  
  1273. % The sort.format.title function returns the the argument,
  1274. % but first any leading "A "'s, "An "'s, or "The "'s are removed.
  1275. % The chop.word function uses s, so we need another string variable, t
  1276.  
  1277. FUNCTION{sort.format.title}
  1278. { 't swap$ :=
  1279.   "A " #2
  1280.     "An " #3
  1281.       "The " #4 t chop.word
  1282.     chop.word
  1283.   chop.word
  1284.   #1 global.string.max substring$
  1285.   purify$
  1286. }
  1287.  
  1288. % There is a limit on the length of an entry string variable, which
  1289. % is what its sort.key$ is.  The limit is currently entry.string.max, so we
  1290. % take at most that many characters of the constructed key, and hope
  1291. % there aren't many references that match to that many characters!
  1292.  
  1293. FUNCTION{presort}
  1294. { author missing$
  1295.     { editor missing$
  1296.     { key field.or.null }
  1297.     { editor sort.format.names }
  1298.       if$
  1299.     }
  1300.     { author sort.format.names }
  1301.   if$
  1302.   "    "
  1303.   *
  1304.   year field.or.null
  1305.   *
  1306.   "    "
  1307.   *
  1308.   title field.or.null
  1309.   sort.format.title
  1310.   *
  1311.   #1 entry.string.max substring$
  1312.   'sort.key$ swap$ :=
  1313. }
  1314.  
  1315. ITERATE{presort}
  1316.  
  1317. % And now we can sort
  1318. %
  1319. % To get the unsorted style (plainu) from this one (plain), it suffices
  1320. % to simply comment out the ITERATE{presort} and SORT commands
  1321.  
  1322. SORT
  1323.  
  1324. %%I CHANGED THIS PART - pfps 
  1325. %% Now comes the computation of the label.  We use numbers, in the sort order.
  1326. %% We have to keep track of the longest (in width$ terms) label, for use
  1327. %% by the "thebibliography" environment.
  1328. %%
  1329. %% For nonnumeric labels, this computation is more complicated.
  1330. %
  1331. %STRINGS{longest.label}
  1332. %
  1333. %INTEGERS{number.label longest.label.width}
  1334. %
  1335. %FUNCTION{initialize.labels}
  1336. %{ 'longest.label "" :=
  1337. %  'number.label #1  :=
  1338. %  'longest.label.width #0 :=
  1339. %}
  1340. %
  1341. %FUNCTION{forward.pass}
  1342. %{ 'label number.label int.to.str$ :=
  1343. %  'number.label number.label #1 + :=
  1344. %  label width$ longest.label.width >
  1345. %    { 'longest.label label :=
  1346. %      'longest.label.width label width$ :=
  1347. %    }
  1348. %    'skip$
  1349. %  if$
  1350. %}
  1351. %
  1352. %EXECUTE{initialize.labels}
  1353. %
  1354. %ITERATE{forward.pass}
  1355. %
  1356. %% Note:  When using nonnumeric labels, the forward.pass must compute those
  1357. %% labels as well as the `b', `c', `d' etc. that will be appended to otherwise
  1358. %% identical labels.  There should then also be a reverse.pass to compute
  1359. %% the `a', do whatever appending needs done, and compute the longest label
  1360. %% (forward.pass can't compute this).
  1361. %
  1362. %% REVERSE{reverse.pass}
  1363. %
  1364. %Now comes the computation of the label.  We use the authors' names,
  1365. %followed by the year of publication, followed by a distinguisher 'a'
  1366. %etc. if necessary.  This has been modified from sample.bst. - pfps
  1367. % Now we finish the computation of each entry's label, putting in
  1368. % the 'a's and 'b's and so forth if required.  This involves two
  1369. % passes: a forward pass to put in the 'b's, 'c's and so on, and 
  1370. % a backwards pass to put in the 'a's.  The second pass also puts
  1371. % the longest label into the variable longestlabel
  1372. %
  1373. % VARS: longest.label, last.label : string
  1374. %       label.width, last.extra   : integer
  1375. %
  1376. % label.format ==
  1377. %  BEGIN
  1378. %    numnames := num.names$(author)
  1379. %       if missing$(author) then label := ""
  1380. %       else if numnames = 1 
  1381. %         then label := format.names$(author,1,"{vv }{ll}")
  1382. %         else if numnames = 2
  1383. %          then label := format.names$(author,1,"{vv }{ll and }") *
  1384. %                format.names$(author,2,"{vv }{ll}")
  1385. %                 else label := format.names$(author,1,"{vv }{ll {\em et al.}}")
  1386. %          fi
  1387. %            fi
  1388. %       fi
  1389. %    if missing$(year) then return label
  1390. %    else return "\protect\citename{" * label * ", }" * year % pfps 9/86
  1391. %  END
  1392. %
  1393. % initialize.labels ==
  1394. %  BEGIN
  1395. %     longest.label := last.label := next.extra := null
  1396. %     label.width   := last.extra := 0
  1397. %  END
  1398. %
  1399. % forward.pass ==
  1400. %  BEGIN
  1401. %   label := label.format()
  1402. %   FPIF: if last.label = label
  1403. %           then last.extra := last.extra + 1
  1404. %                extralabel := ascii$(`a + last.extra)
  1405. %           else last.extra := 0
  1406. %                extralabel := null
  1407. %         fi
  1408. %  END
  1409. %
  1410. % reverse.pass ==
  1411. %  BEGIN
  1412. %     if next.extra = "b"
  1413. %             then extralabel := "a"
  1414. %           fi
  1415. %           label := label * extralabel
  1416. %%    if width${label} > label.width
  1417. %%             then longest.label := label
  1418. %%                  label.width := width${label}
  1419. %%           fi
  1420. %           next.extra := extralabel
  1421. %  END
  1422.  
  1423. STRINGS{last.label next.extra}
  1424. INTEGERS{last.extra}
  1425.  
  1426. FUNCTION{initialize.labels}
  1427. { 'last.label ""    :=
  1428.   'next.extra ""    :=
  1429.   'last.extra  #0    :=
  1430. %  'label.width #0    :=
  1431. %  'longest.label "" :=
  1432. }
  1433.  
  1434. FUNCTION{label.format.names}
  1435. { 's swap$ :=
  1436.   'numnames s num.names$ :=
  1437.   numnames #1 =
  1438.     { 's s #1 "{vv }{ll}" format.name$ := }
  1439.     { numnames #2 =
  1440.         { 's s #1 "{vv }{ll }and " format.name$
  1441.          s #2 "{vv }{ll}" format.name$ * :=
  1442.         }
  1443.         { 's s #1 "{vv }{ll }\bgroup \em et al.\egroup " format.name$ := }
  1444.       if$
  1445.     }
  1446.   if$
  1447.   s
  1448. }
  1449.  
  1450. FUNCTION{label.format}
  1451. { author missing$
  1452.     { editor missing$
  1453.         { 'label "" := }
  1454.     { 'label editor label.format.names := }
  1455.       if$
  1456.     }
  1457.     { 'label author label.format.names := }
  1458.   if$
  1459.   year missing$
  1460.     { label } % pfps 9/86
  1461.     { label "" = 
  1462.       {""} 
  1463.       {"\protect\citename{" label * ", }" *}  % pfps 9/86
  1464.       if$ 
  1465.       year * }
  1466.   if$
  1467. }
  1468.  
  1469. FUNCTION{forward.pass}
  1470. { 'label label.format :=
  1471.   label last.label = 
  1472.     { 'last.extra last.extra #1 +  := 
  1473.       'extralabel  #97 last.extra + int.to.chr$ :=
  1474.     }
  1475.     { 'last.extra #0 :=
  1476.       'extralabel "" :=
  1477.     }
  1478.   if$
  1479.   'last.label label :=
  1480. }
  1481.  
  1482. FUNCTION{reverse.pass}
  1483. { next.extra "b" = 
  1484.     { 'extralabel "a" :=}
  1485.     'skip$
  1486.   if$
  1487.   'label label extralabel * :=
  1488.   'next.extra extralabel :=
  1489. %  label.width label width$ > 
  1490. %    'skip$
  1491. %    { 'longest.label label :=
  1492. %      'label.width  label width$    :=
  1493. %    }
  1494. %  if$
  1495. }
  1496.  
  1497. EXECUTE{initialize.labels}
  1498. ITERATE{forward.pass}
  1499. REVERSE{reverse.pass}
  1500.  
  1501.  
  1502.  
  1503. % Now we're ready to start writing the .BBL file.  First we write
  1504. % the `preamble' containing the command
  1505. %     \begin{thebibliography}{...}
  1506. % where the `...' is the longest label.
  1507. % Also, we call init.state.consts, for use by the output routines.
  1508. %
  1509. % The following \sfcode declaration causes a `.' (period) not to
  1510. % produce an end-of-sentence space.  Each entry is divided into
  1511. % `blocks', which are separated by a \newblock command.  The following
  1512. % \def command defines \newblock to add horizontal space, giving
  1513. % a `closed' format.
  1514. %    \def\newblock{\hskip .11em plus .33em minus -.07em}
  1515. %    \sfcode`\.=1000\relax
  1516. %
  1517. % For an `open' format (each block on a new line), replace these commands by:
  1518. %    \def\newblock{\\\relax}
  1519.  
  1520. FUNCTION{preamble}
  1521. { init.state.consts
  1522.   "\begin{thebibliography}{"  "xx" % longest.label
  1523.                   * "}" * write$
  1524.   newline$
  1525.   "% The newblock command here creates a `closed' format" write$
  1526.   newline$
  1527.   "% and the sfcode command affects the spacing after a period;" write$
  1528.   newline$
  1529.   "% for more details please ask a style designer." write$
  1530.   newline$
  1531.   "\def\newblock{\hskip .11em plus .33em minus -.07em}" write$
  1532.   "\sfcode`\.=1000\relax" write$
  1533.   newline$
  1534. }
  1535.  
  1536. EXECUTE{preamble}
  1537.  
  1538. % Now we execute to produce the output for all the entries
  1539.  
  1540. ITERATE{call.type$}
  1541.  
  1542. % Finally, we finish up by writing the `\end{thebibliography}' command.
  1543.  
  1544. FUNCTION{finish.up}{ newline$ "\end{thebibliography}" write$ newline$}
  1545.  
  1546. EXECUTE{finish.up}
  1547.